<template>
	<view class="fixbg" v-if="imageURL && imageURL!=''" :style="{'background-image' : 'url(' + imageURL + ')'}">
		<view :class="[textclass]"><!--创建flex，理解为大的盒子-->
			<view class="cotion">保存成功</view>
			<view class="back" @click="backto()">返回书架</view>
		</view>		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content:{},
				textclass: 'text',
				imageURL:'',
				id: 0,
				continue_id: 0
			}
		},
		
		onLoad(e) {//在页面加载时获取数据
			
			this.id = e.nextid,
			this.continue_id = e.nowpage,
			console.log("e.nextid" + e.nextid),
			console.log("e.nowpage" + e.nowpage),
			// this.savecontinue_id(),
			this.getbookleaves()
			
		},
		
		methods: {
			//回到书架界面并更新数据
			backto(){
				this.continue_id = Number(this.continue_id)//直接获取到的e为字符串类型，转换成int
				// console.log("当前页码",this.continue_id)
				const db = uniCloud.database()
				const dbCmd = db.command
				const collection = db.collection('book_first')
				let res = collection.doc("61af4b100f30890001d97cba")
				.update({
					"continuetext_id": this.continue_id
				})
				uni.redirectTo({
					url:"../book_shelf/book_shelf"
				})
			},
			//获取渲染当前封面的相关数据
			getbookleaves(){
				this.id = Number(this.id)//直接获取到的e为字符串类型，转换成int
				// console.log(this.id)
				const db = uniCloud.database()
				const collection = db.collection('book_first')
				let res = collection.where({pic_id:this.id})
				.get()
				.then(res => {
					// console.log(res)//调试，将内容打印到consolelog界面
					this.content = res.result.data[0]
					this.imageURL = res.result.data[0].bannerfile.url
					// console.log(this.content)
				})
			}
			
		}
	}
</script>

<style>
	.text{
		height: 1400rpx;/*屏幕大小750rpx * 1400rpx*/
	    font-size:60rpx;
	    color:#00aaff;
		display: flex;
		flex-direction: column;
		/* top:calc(var(--window-top) + 10px) */
	}
	.cotion{
		width: 300rpx;
		height: 150rpx;
		margin: 800rpx 0rpx 0rpx 250rpx;/*上右下左*/
	}
	.back{
		width: 300rpx;
		height: 150rpx;
		margin: 0rpx 0rpx 0rpx 250rpx;/*上右下左*/
	}
</style>
